#include "volume_meter.hpp"
#include <QPainter>

VolumeMeter::VolumeMeter(QWidget *parent):
    QWidget(parent),
    volume_(0.33)
{
}

QSize VolumeMeter::sizeHint() const
{
    return QSize(50, 1);
}

void VolumeMeter::paintEvent(QPaintEvent *event)
{
    QWidget::paintEvent(event);
    QPainter p(this);
    p.setBrush(Qt::green);
    p.setPen(Qt::NoPen);
    p.drawRect(0, 0, volume_ * width(), height());
}

void VolumeMeter::setVolume(float value)
{
    volume_ = value;
}

float VolumeMeter::volume() const
{
    return volume_;
}
